package org.example.server.service.impl;

import org.example.dto.DepartmentDTO;
import org.example.dto.DoctorDTO;
import org.example.dto.OrgInfoDTO;
import org.example.entity.Department;
import org.example.entity.DoctorInfo;
import org.example.entity.OrgInfo;
import org.example.server.mapper.DepartmentMapper;
import org.example.server.mapper.DoctorMapper;
import org.example.server.mapper.OrgInfoMapper;
import org.example.server.service.DoctorService;
import org.example.vo.DoctorVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DoctorServiceImpl implements DoctorService {

    @Resource
    private OrgInfoMapper orgInfoMapper;
    @Resource
    private DepartmentMapper departmentMapper;
    @Resource
    private DoctorMapper doctorMapper;

    @Override
    public DoctorVO selectByDoctor(DoctorDTO doctorDTO) {

        OrgInfo orgInfo = orgInfoMapper.selectByNo(doctorDTO.getHospitalNo());
        Department department = departmentMapper.selectByCode(doctorDTO);
        DoctorInfo doctorInfo = doctorMapper.selectByCode(doctorDTO);


      DoctorVO doctorVO=new DoctorVO();
        if (orgInfo!=null&&department!=null&&doctorInfo!=null){
      BeanUtils.copyProperties(doctorInfo,doctorVO);

      doctorVO.setHospitalName(orgInfo.getHospitalName());
      doctorVO.setDeptName(department.getDepartmentName());


}
        return doctorVO;
    }
}
